package com.zhongyu.base.provider.apiimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhongyu.base.provider.mapper.ImageMapper;
import com.zhongyu.comm.api.ImageApi;
import com.zhongyu.comm.pojo.Image;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ImageApiImpl  implements ImageApi {

    @Resource
    private ImageMapper imageMapper;


    @Override
    public Image findOne(Integer targetId, Integer type, Integer category) {
        QueryWrapper<Image> queryWrapper= Wrappers.query();
        queryWrapper.eq("target_id",targetId)
                .eq("type",type)
                .eq("category",category);
        Image image= imageMapper.selectOne(queryWrapper);
        if (image==null){
            image=new Image();
            image.setImgUrl("https://img.alicdn.com/bao/uploaded/https://img.alicdn.com/imgextra/i1/2251059038/O1CN01MtG4qQ2GdSFfo0d4g_!!2251059038.png");
        }
        return image;
    }
}
